home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / recover / recoverServerPreparedTrans.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.8 KB  |  181 lines

  1. /*
  2.  *   $RCSfile: recoverServerPreparedTrans.c,v $  
  3.  *   $Revision: 1.2 $  
  4.  *   $Date: 1996/05/04 23:51:53 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "link.h"
  53. #include "lsn.h"
  54. #include "latch.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "trans.h"
  58. #include "openlog.h"
  59. #include "logrecs.h"
  60. #include "bitvec.h"
  61. #include "trans_extfuncs.h"
  62. #include "trans_intfuncs.h"
  63. #include "recover_intfuncs.h"
  64. #include "msg_funcs.h"
  65. #include "cl_funcs.h"
  66. #include "thread_funcs.h"
  67. #include "thread_globals.h"
  68. #include "trans_globals.h"
  69. #include "distr.h"
  70. #include "distr_intfuncs.h"
  71.  
  72. #ifdef vax
  73.  void
  74. recoverServerPreparedTrans (
  75.     register TRANSREC   *transRec,
  76. )
  77. #elif defined(mips) || defined(sparc) || defined(_AIX) || defined(hpux) || defined(linux)
  78.  void
  79. recoverServerPreparedTrans ()
  80. #elif !(defined(mips) || defined(sparc) || defined(vax) || defined(_AIX) || defined(hpux) || defined(linux))
  81.     not supported
  82. #else
  83.     /* this else should have the not supported code, but the
  84.        ultrix cpp is broken */
  85. #endif
  86.  
  87. {
  88.     TID    localTid;
  89.     TID    coordTid;
  90.     /*
  91.      *    This variable holds an argument passed the this function
  92.      *    when the thread was forked.     This should be portable across
  93.      *    all architectures but vax's.
  94.      */
  95. #if defined(mips) || defined(sparc) || defined(_AIX) || defined(hpux) || defined(linux)
  96.     register TRANSREC   *transRec;
  97. #elif defined(vax)
  98.     /* not needed */
  99. #elif !(defined(mips) || defined(sparc) || defined(vax) || defined(_AIX) || defined(hpux) || defined(linux))
  100.     not supported
  101. #else
  102.     /* this else should have the not supported code, but the
  103.        ultrix cpp is broken */
  104. #endif 
  105.  
  106.     TRACE(TR_TRANS, TR_LEVEL_1);
  107.  
  108.     /*
  109.      *    suck the transrec out of the tcb buffer
  110.      */
  111. #ifdef mips
  112.     transRec = (TRANSREC *) Active->currentBuf[JB_A0];
  113. #elif defined(sparc) || defined(_AIX) || defined(hpux) || defined(linux)
  114.     /*
  115.      *    Sparc and other architectures
  116.      */
  117.     transRec = (TRANSREC *) Active->args[0];
  118. #elif defined(vax)
  119.     /* not needed */
  120. #elif !(defined(mips) || defined(sparc) || defined(vax) || defined(_AIX) || defined(hpux) || defined(linux))
  121.     not supported
  122. #else
  123.     /* this else should have the not supported code, but the
  124.        ultrix cpp is broken */
  125. #endif 
  126.  
  127.  
  128.     localTid = transRec->tid;
  129.     coordTid = transRec->coordTid;
  130.  
  131.  
  132.     TRPRINT(TR_TRANS, TR_LEVEL_1, ("localTid:%x", localTid));
  133.  
  134.     /*
  135.      *    initialize the version, type, coordTid, and localTid of 
  136.      *    the reply message
  137.      */
  138.     Active->message.header.version = MESSAGE_VERSION;
  139.     Active->message.header.type = SERVER_VOTE;
  140.     Active->message.body.vote.coordTid = coordTid;
  141.     Active->message.body.vote.localTid = localTid;
  142.  
  143.     /*
  144.      *    record the vote 
  145.      */
  146.     Active->message.body.vote.vote = YESVOTE;
  147.  
  148.     /*
  149.      *    mark the active transaction
  150.      */
  151.     Active->transRec = (char *) transRec;
  152.  
  153.     /*
  154.      *    fill in the other Active fields
  155.      */
  156.     Active->replyAddr = transRec->coordAddr;
  157.  
  158.     /*
  159.      *    mark this thread  as the master for this trans
  160.      */
  161.     transRec->masterThread = Active;
  162.  
  163.     /*
  164.      *    keep sending the vote until reply is recd
  165.      */
  166.     while (transRec->coordCommand == C_UNKNOWN)    {
  167.             
  168.         replyDatagram(esmNOERROR, esmNOERROR, 1, FALSE);
  169.         /*
  170.          *    go to sleep on timeout
  171.          */
  172.         Sleep(T_SERVERTIMEOUT);
  173.     }
  174.  
  175.     /*
  176.      *    commit/abort based on command
  177.      *    reply to coord
  178.      */
  179.     replyWithAck(transRec);
  180. }
  181.